<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

class DataRealisasiES1 {

    private $db;
    private $_period_name;
    private $_satker;
    private $_code_id;
    private $_kppn;
    private $_akun;
    private $_program;
    private $_output;
    private $_dana;
    private $_bank;
    private $_kewenangan;
    private $_lokasi;
    private $_budget_type;
    private $_currency_code;
    private $_budget_amt;
    private $_encumbrance_amt;
    private $_actual_amt;
    private $_balancing_amt;
    private $_nm_satker;
    private $_obligation;
    private $_block_amount;
    private $_temp_block;
    private $_cash_limit;
	private $_pengembalian;
	private $_provinsi;
	private $_nmlokasi;
    private $_invoice;
	private $_tgl;
	private $_nodok;
	private $_jan;
	private $_feb;
	private $_mar;
	private $_apr;
	private $_mei;
	private $_jun;
	private $_jul;
	private $_agt;
	private $_sep;
	private $_okt;
	private $_nov;
	private $_des;
    private $_table1 = 'GL_BALANCES_V';
    private $_table2 = 'T_BA';
    private $_table3 = 'T_KEGIATAN';
    private $_table4 = 'T_ESELON1';
    private $_table6 = 'T_OUTPUT';
    private $_table5 = 'T_AKUN';
    private $_table7 = 'BLOCK_REVISI';
    private $_table8= 'T_SATKER';
	private $_table9= 'PENGEMBALIAN_PEND';
	private $_table10= 'DETAIL_PENGEMBALIAN_PEND';
    public $registry;

    /*
     * konstruktor
     */

    public function __construct($registry = Registry) {
        $this->db = $registry->db;
        $this->registry = $registry;

        if (('' . Session::get('ta')) == date("Y")) {
            $this->_table1 = 'GL_BALANCES_V';
            $this->_table8 = 'T_SATKER';
			$this->_table_transfer = 'DM_REALISASI_TRANSFER';
        } else {
            $this->_table1 = 'GL_BALANCES_V_TL';
            $this->_table8 = 't_satker_tl';
			$this->_table_transfer = 'DM_REALISASI_TRANSFER_14';
        }
        $this->_table7="(SELECT * FROM BLOCK_REVISI WHERE PERIOD_YEAR=".Session::get('ta').")";
    }

    /*
     * mendapatkan data dari tabel Data Tetap
     * @param limit batas default null
     * return array objek Data Tetap */





    /* ----------------------------------------------------------------------------------------------------------- contekan */

    public function get_ba_kegiatan_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT SUBSTR(OUTPUT,1,4) KODE_KEGIATAN, C.NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  "
                . $this->_table3 . " C ON SUBSTR(A.OUTPUT,1,4)=C.KDKEGIATAN LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY SUBSTR(OUTPUT,1,4), C.NMKEGIATAN";
        $sql .= " ORDER BY SUBSTR(OUTPUT,1,4) ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }

    public function get_es1_kegiatan_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT SUBSTR(OUTPUT,1,4) KODE_KEGIATAN, C.NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI, B.NMES1 , B.KDES1
				FROM "
                . $this->_table1 . " A, "
                . $this->_table4 . " B, "
                . $this->_table3 . " C 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' AND
				AND SUBSTR(A.PROGRAM,1,5)=B.KDES1
				SUBSTR(A.OUTPUT,1,4)=C.KDKEGIATAN			
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
				
				";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY SUBSTR(OUTPUT,1,4), C.NMKEGIATAN ,B.NMES1 , B.KDES1";
        $sql .= " ORDER BY SUBSTR(OUTPUT,1,4) ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['BUDGET_AMT']);
            $d_data->set_actual_amt($val['ACTUAL_AMT']);
            $d_data->set_nm_satker($val['NMBA']);
            $data[] = $d_data;
        }
        return $data;
    }
	/* DARI GL_BALANCES_V
    public function get_ba_pendapatan_filter($filter) {
        Session::get('id_user');
        $sql = " SELECT A.AKUN, A.DESCRIPTION, SUM(PAGU) PAGU	,SUM(D.TOTAL) POTONGAN, SUM(REALISASI) - NVL(SUM(D.TOTAL),0) SETORAN, SUM(REALISASI) REALISASI, A.KDBA
		FROM (
		SELECT A.SATKER, A.AKUN, C.DESCRIPTION, SUM(BUDGET_AMT) PAGU
		,  SUM(ACTUAL_AMT) * -1 REALISASI, B.BA KDBA
				FROM "
                . $this->_table1 . " A, "
                . $this->_table5 . " C , 
				( SELECT DISTINCT KDSATKER, BA, KANWIL_DJPB, BAES1 FROM " . $this->_table8 . " ) B  				
				WHERE 1=1 
				AND A.AKUN =C.FLEX_VALUE			
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) = '4'
				AND BUDGET_TYPE IN ('2','7')
				AND A.SATKER = B.KDSATKER								
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) <> 0
				
				";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY A.AKUN, C.DESCRIPTION, B.BA, A.SATKER )A  ";
		$sql .= " LEFT JOIN
					( SELECT DISTINCT AKUN, SATKER, SUM(NILAI_ORI)TOTAL FROM SPPM_BPN WHERE SUBSTR(JENDOK_EXIS,1,1) NOT IN ('3','4','5','6') AND BUDGET = '2' GROUP BY AKUN, SATKER ) D
					ON A.SATKER = D.SATKER
					AND A.AKUN = D.AKUN ";
		 $sql .= " GROUP BY A.AKUN,  A.DESCRIPTION,  A.KDBA ";

        $sql .= " ORDER BY A.AKUN ";


        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['AKUN']);
            $d_data->set_nmkegiatan($val['DESCRIPTION']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
			$d_data->set_dana($val['POTONGAN']);
			$d_data->set_bank($val['SETORAN']);
            $data[] = $d_data;
        }
        return $data;
    }
	*/
	public function get_ba_pendapatan_filter($filter) {
        Session::get('id_user');
        $sql = " SELECT 
					A.AKUN,
					C.DESCRIPTION,
					SUM(CASE WHEN JE_SOURCE IN ('Payables','Manual') AND BUD_TYPE = '2' THEN RPHREAL *-1 ELSE 0 END) POTONGAN,
					SUM(CASE WHEN JE_SOURCE IN ('Payables','Manual') AND BUD_TYPE = '7' THEN RPHREAL *-1 ELSE 0 END) PENGEMBALIAN,
					SUM(CASE WHEN JE_SOURCE IN ('Receivables','Conversion') THEN RPHREAL *-1 ELSE 0 END) SETORAN,
					SUM(RPHREAL *-1) REALISASI
						FROM
					GL_JE_LINES A,
					T_AKUN C,
					( SELECT DISTINCT KDSATKER, CASE WHEN KDSATKER LIKE '%Z%' THEN 'ZZZ' ELSE BA END BA, KANWIL_DJPB, BAES1 FROM " . $this->_table8 . " ) B
					WHERE A.AKUN = C.FLEX_VALUE (+)
					AND SUBSTR(A.AKUN,1,1) = '4'
					AND A.KDSATKER = B.KDSATKER(+)					
				";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY A.AKUN, C.DESCRIPTION ";
        $sql .= " ORDER BY A.AKUN ";


        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['AKUN']);
            $d_data->set_nmkegiatan($val['DESCRIPTION']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
			$d_data->set_dana($val['POTONGAN']);
			$d_data->set_bank($val['SETORAN']);
			$d_data->set_pengembalian($val['PENGEMBALIAN']);
            $data[] = $d_data;
        }
        return $data;
    }
	//TEST MENKEU PER AKUN LAYER DARI PER KL
	public function get_ba_pendapatan_per_akun_menkeu($filter) {
        Session::get('id_user');
        $sql = " SELECT 
					A.AKUN,
					C.DESCRIPTION,
					SUM(CASE WHEN JE_SOURCE IN ('Payables','Manual') AND BUD_TYPE = '2' THEN RPHREAL *-1 ELSE 0 END) POTONGAN,
					SUM(CASE WHEN JE_SOURCE IN ('Payables','Manual') AND BUD_TYPE = '7' THEN RPHREAL *-1 ELSE 0 END) PENGEMBALIAN,
					SUM(CASE WHEN JE_SOURCE IN ('Receivables','Conversion') THEN RPHREAL *-1 ELSE 0 END) SETORAN,
					SUM(RPHREAL *-1) REALISASI
						FROM
					GL_JE_LINES A,
					T_AKUN C,
					( SELECT DISTINCT KDSATKER, BA FROM T_SATKER_ALL  ) B
					WHERE A.AKUN = C.FLEX_VALUE (+)
					AND SUBSTR(A.AKUN,1,1) = '4'
					AND A.KDSATKER = B.KDSATKER(+)					
				";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY A.AKUN, C.DESCRIPTION ";
        $sql .= " ORDER BY A.AKUN ";


        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['AKUN']);
            $d_data->set_nmkegiatan($val['DESCRIPTION']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
			$d_data->set_dana($val['POTONGAN']);
			$d_data->set_bank($val['SETORAN']);
			$d_data->set_pengembalian($val['PENGEMBALIAN']);
            $data[] = $d_data;
        }
        return $data;
    }
	public function get_ba_pendapatan_menkeu($filter) {
        Session::get('id_user');
        //diubah ke satu table biar performa oke
		/*$sql = " SELECT 
					A.AKUN,
					C.DESCRIPTION,
					SUM(CASE WHEN JE_SOURCE IN ('Payables','Manual') AND BUD_TYPE = '2' THEN RPHREAL *-1 ELSE 0 END) POTONGAN,
					SUM(CASE WHEN JE_SOURCE IN ('Payables','Manual') AND BUD_TYPE = '7' THEN RPHREAL *-1 ELSE 0 END) PENGEMBALIAN,
					SUM(CASE WHEN JE_SOURCE IN ('Receivables','Conversion') THEN RPHREAL *-1 ELSE 0 END) SETORAN,
					SUM(RPHREAL *-1) REALISASI
						FROM
					GL_JE_LINES A,
					T_AKUN C,
					(SELECT DISTINCT KDSATKER, CASE WHEN KDSATKER LIKE 'Z%' THEN 'ZZZ' ELSE BA END BA FROM T_SATKER) B
					WHERE A.AKUN = C.FLEX_VALUE (+)
					AND SUBSTR(A.AKUN,1,1) = '4'
					AND TGLPOST <= TRUNC(SYSDATE-1)
					AND A.KDSATKER = B.KDSATKER(+)					
				";*/
		$sql = " SELECT * FROM PENDAPATAN_PER_AKUN_MENKEU ";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        //$sql .= " GROUP BY A.AKUN, C.DESCRIPTION ";
        //$sql .= " ORDER BY A.AKUN ";


        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['AKUN']);
            $d_data->set_nmkegiatan($val['DESCRIPTION']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
			$d_data->set_dana($val['POTONGAN']);
			$d_data->set_bank($val['SETORAN']);
			$d_data->set_pengembalian($val['PENGEMBALIAN']);
            $data[] = $d_data;
        }
        return $data;
    }
	
	public function get_pengembalian_pendapatan($filter) {
        Session::get('id_user');
        $sql = " SELECT * FROM " 				
				. $this->_table9. " WHERE 1=1 ";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        //$sql .= " GROUP BY A.AKUN, C.DESCRIPTION ";
        $sql .= " ORDER BY KDSATKER ";


        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDSATKER']);
			$d_data->set_nm_satker($val['NMSATKER']);
			$d_data->set_program($val['BAES1']);
            $d_data->set_jan($val['JAN']);
            $d_data->set_feb($val['FEB']);
            $d_data->set_mar($val['MAR']);
            $d_data->set_apr($val['APR']);
            $d_data->set_mei($val['MEI']);
			$d_data->set_jun($val['JUN']);
			$d_data->set_jul($val['JUL']);
			$d_data->set_agt($val['AGT']);
			$d_data->set_sep($val['SEP']);
			$d_data->set_okt($val['OKT']);
			$d_data->set_nov($val['NOV']);
			$d_data->set_des($val['DES']);
			$d_data->set_balancing_amt($val['TOTAL']);
            $data[] = $d_data;
        }
        return $data;
    }
	
	public function get_realisasi_transfer_perbulan($filter) {
        Session::get('id_user');
        $sql = 
			"SELECT 
			  KDPROVINSI,
			  PROVINSI,
			  LOKASI ,
			  NMLOKASI ,
			  SUM(JAN) JAN,
			  SUM(FEB) FEB,
			  SUM(MAR) MAR,
			  SUM(APR) APR,
			  SUM(MEI) MEI,
			  SUM(JUN) JUN,
			  SUM(JUL) JUL,
			  SUM(AGT) AGT,
			  SUM(SEP) SEP,
			  SUM(OKT) OKT,
			  SUM(NOV) NOV,
			  SUM(DES) DES,
			  SUM(REALISASI) REALISASI 
			  
			  FROM ".$this->_table_transfer." WHERE 1=1";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY KDPROVINSI, PROVINSI, LOKASI, NMLOKASI  ";
        $sql .= " ORDER BY LOKASI ";


        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_provinsi($val['PROVINSI']);
			$d_data->set_lokasi($val['LOKASI']);
			$d_data->set_nmlokasi($val['NMLOKASI']);
            $d_data->set_jan($val['JAN']);
            $d_data->set_feb($val['FEB']);
            $d_data->set_mar($val['MAR']);
            $d_data->set_apr($val['APR']);
            $d_data->set_mei($val['MEI']);
			$d_data->set_jun($val['JUN']);
			$d_data->set_jul($val['JUL']);
			$d_data->set_agt($val['AGT']);
			$d_data->set_sep($val['SEP']);
			$d_data->set_okt($val['OKT']);
			$d_data->set_nov($val['NOV']);
			$d_data->set_des($val['DES']);
			$d_data->set_balancing_amt($val['REALISASI']);
            $data[] = $d_data;
        }
        return $data;
    }
	
	public function get_detail_pengembalian_pendapatan($filter) {
        Session::get('id_user');
        $sql = " SELECT * FROM " 				
				. $this->_table10. " WHERE 1=1 ";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        //$sql .= " GROUP BY A.AKUN, C.DESCRIPTION ";
        $sql .= " ORDER BY KDSATKER ";


        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDSATKER']);
			$d_data->set_akun($val['AKUN']);
			$d_data->set_pengembalian($val['DESCRIPTION']);
			$d_data->set_balancing_amt($val['RPHREAL']);
			$d_data->set_tgl($val['TGLPOST']);
			$d_data->set_nodok($val['NODOK']);
            $data[] = $d_data;
        }
        return $data;
    }
	
	public function get_kanwil_pendapatan_filter($filter) {
        Session::get('id_user');
        $sql = " SELECT A.AKUN, A.DESCRIPTION, SUM(PAGU) PAGU	,SUM(D.TOTAL) POTONGAN, SUM(REALISASI) - NVL(SUM(D.TOTAL),0) SETORAN, SUM(REALISASI) REALISASI
		FROM (
		SELECT A.SATKER, A.AKUN, C.DESCRIPTION, SUM(BUDGET_AMT) PAGU
		,  SUM(ACTUAL_AMT) * -1 REALISASI, B.BA KDBA
				FROM "
                . $this->_table1 . " A, "
                . $this->_table5 . " C , 
				( SELECT DISTINCT KDSATKER, BA, KANWIL_DJPB, BAES1 FROM " . $this->_table8 . " ) B  				
				WHERE 1=1 
				AND A.AKUN =C.FLEX_VALUE			
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) = '4'
				AND BUDGET_TYPE = '2'
				AND A.SATKER = B.KDSATKER								
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) <> 0
				
				";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY A.AKUN, C.DESCRIPTION, B.BA, A.SATKER )A  ";
		$sql .= " LEFT JOIN
					( SELECT DISTINCT AKUN, SATKER, SUM(NILAI_ORI)TOTAL FROM SPPM_BPN WHERE SUBSTR(JENDOK_EXIS,1,1) NOT IN ('3','4','5','6') AND BUDGET = '2' GROUP BY AKUN, SATKER ) D
					ON A.SATKER = D.SATKER
					AND A.AKUN = D.AKUN ";
		 $sql .= " GROUP BY A.AKUN,  A.DESCRIPTION ";

        $sql .= " ORDER BY A.AKUN ";


        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['AKUN']);
            $d_data->set_nmkegiatan($val['DESCRIPTION']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
			$d_data->set_dana($val['POTONGAN']);
			$d_data->set_bank($val['SETORAN']);
            $data[] = $d_data;
        }
        return $data;
    }
	
	public function get_ba_per_satker_pendapatan_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT C.NMSATKER, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT)* -1 REALISASI, A.SATKER, SUBSTR(PROGRAM,1,5) KDBA
				FROM "
                . $this->_table1 . " A, 
                ( SELECT DISTINCT KDSATKER, nmsatker,BA, BAES1 FROM " . $this->_table8.")  C 
				WHERE 1=1 
				AND A.SATKER =C.KDSATKER			
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(AKUN,1,1) = '4'
				AND BUDGET_TYPE IN ('2','7')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) <> 0
				
				";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY A.SATKER, C.NMSATKER ";
        $sql .= " ORDER BY A.SATKER ";


        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['SATKER']);
            $d_data->set_nmkegiatan($val['NMSATKER']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            
            $data[] = $d_data;
        }
        return $data;
    }
	
	
    
	public function get_ba_per_es1_pendapatan_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT C.NMES1, SUM(BUDGET_AMT) PAGU
		, SUM(ACTUAL_AMT) * -1 REALISASI, B.BAES1 KDES1
				FROM "
                . $this->_table1 . " A, "
                . $this->_table4 . " C , 
				( SELECT DISTINCT KDSATKER, BA, BAES1 FROM " . $this->_table8 . " ) B
				WHERE 1=1 
				AND B.BAES1 =C.KDES1	
				AND A.SATKER = B.KDSATKER				
				AND A.SUMMARY_FLAG = 'N' 
				AND BUDGET_TYPE IN ('2','7')
				AND SUBSTR(AKUN,1,1) = '4'
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) <> 0
				
				";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY B.BAES1, C.NMES1 ";
        $sql .= " ORDER BY B.BAES1 ";


        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KDES1']);
            $d_data->set_nmkegiatan($val['NMES1']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            
            $data[] = $d_data;
        }
        return $data;
    }
	
	public function get_ba_per_kl_pendapatan_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT 
					B.BA KDES1,
					C.NMBA NMES1,
					SUM(RPHREAL *-1) REALISASI
					FROM
					GL_JE_LINES A,
					(SELECT DISTINCT KDSATKER, CASE WHEN KDSATKER LIKE 'Z%' THEN 'ZZZ' ELSE BA END BA FROM T_SATKER) B,
					T_BA C
					WHERE A.KDSATKER = B.KDSATKER(+)
					AND B.BA = C.KDBA(+)
					AND SUBSTR(A.AKUN,1,1) = '4'
					
				";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY B.BA, C.NMBA ";
        $sql .= " ORDER BY B.BA ";


        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KDES1']);
            $d_data->set_nmkegiatan($val['NMES1']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            
            $data[] = $d_data;
        }
        return $data;
    }
	
	public function get_per_kl_pendapatan_menkeu($filter) {
        Session::get('id_user');
        $sql = "SELECT * FROM PENDAPATAN_PER_KL_MENKEU
										
				";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        //$sql .= " GROUP BY B.BA, C.NMBA ";
        //$sql .= " ORDER BY B.BA ";


        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KDES1']);
            $d_data->set_nmkegiatan($val['NMES1']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            
            $data[] = $d_data;
        }
        return $data;
    }
	
	public function get_kl_per_es1satker_pendapatan_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT BAES1 KODE, C.NMES1 NAMA, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT)* -1 REALISASI 
				FROM "
                . $this->_table1 . " A, "
                . $this->_table4 . " C, 
				( SELECT DISTINCT KDSATKER, BA, BAES1 FROM " . $this->_table8 . " ) B  	
				WHERE 1=1 
							
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(AKUN,1,1) = '4'
				AND A.SATKER = B.KDSATKER
				AND BUDGET_TYPE IN ('2','7')
				AND C.KDES1 = B.BAES1
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) <> 0
				
				";
        $no = 0;
        foreach ($filter as $filter1) {
            $sql .= " AND " . $filter1;
        }
        $sql .= " GROUP BY BAES1, C.NMES1 ";
		$sql .= " UNION ALL ";
		$sql .= "SELECT BAES1 || '-' || A.SATKER KODE, UPPER(B.NMSATKER) NAMA, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT)* -1 REALISASI 
				FROM "
                . $this->_table1 . " A, 
                ( SELECT DISTINCT NMSATKER, KDSATKER, BA, BAES1 FROM " . $this->_table8 . " ) B 				
				WHERE 1=1 
				AND A.SATKER =B.KDSATKER			
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(AKUN,1,1) = '4'
				AND BUDGET_TYPE IN ('2','7')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) <> 0
				
				";
        $no = 0;
        foreach ($filter as $filter2) {
            $sql .= " AND " . $filter2;
        }
        $sql .= " GROUP BY BAES1, A.SATKER, B.NMSATKER ";
        $sql .= " ORDER BY KODE ";
        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE']);
            $d_data->set_nmkegiatan($val['NAMA']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            
            $data[] = $d_data;
        }
        return $data;
    }
	
	public function get_kanwil_per_es1satker_pendapatan_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT BA KODE, C.NMBA NAMA, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT)* -1 REALISASI 
				FROM "
                . $this->_table1 . " A, "
                . $this->_table2 . " C, 
				( SELECT DISTINCT KDSATKER, BA,KANWIL_DJPB, BAES1 FROM " . $this->_table8 . " ) B  	
				WHERE 1=1 
							
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(AKUN,1,1) = '4'
				AND A.SATKER = B.KDSATKER
				AND BUDGET_TYPE IN ('2','7')
				AND C.KDBA = B.BA
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) <> 0
				
				";
        $no = 0;
        foreach ($filter as $filter1) {
            $sql .= " AND " . $filter1;
        }
        $sql .= " GROUP BY BA, C.NMBA ";
		$sql .= " UNION ALL ";
		$sql .= "SELECT BAES1 || '-' || A.SATKER KODE, UPPER(B.NMSATKER) NAMA, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT)* -1 REALISASI 
				FROM "
                . $this->_table1 . " A, 
                ( SELECT DISTINCT NMSATKER, KDSATKER, BA, KANWIL_DJPB, BAES1 FROM " . $this->_table8 . " ) B 				
				WHERE 1=1 
				AND A.SATKER =B.KDSATKER			
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(AKUN,1,1) = '4'
				AND BUDGET_TYPE IN ('2','7')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) <> 0
				
				";
        $no = 0;
        foreach ($filter as $filter2) {
            $sql .= " AND " . $filter2;
        }
        $sql .= " GROUP BY BAES1, A.SATKER, B.NMSATKER ";
        $sql .= " ORDER BY KODE ";
        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE']);
            $d_data->set_nmkegiatan($val['NAMA']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            
            $data[] = $d_data;
        }
        return $data;
    }
	
/* fungsi di bawah ini dipakai juga utk eselon1 per output*/
    public function get_ba_output_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT SUBSTR(OUTPUT,1,4) KODE_KEGIATAN, C.NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  "
                . $this->_table3 . " C ON SUBSTR(A.OUTPUT,1,4)=C.KDKEGIATAN LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID LEFT JOIN "
                . $this->_table6 . " D ON SUBSTR(A.output,1,4)=d.KDKEGIATAN
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
                                AND SUBSTR(A.AKUN,1,1) IN('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
				";

        foreach ($filter as $filter1) {
            $sql .= " AND " . $filter1;
        }
        $sql .= " GROUP BY SUBSTR(OUTPUT,1,4), C.NMKEGIATAN ";
        $sql .=" union all 
                SELECT OUTPUT KODE_KEGIATAN, d.NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  "
                . $this->_table6 . " D ON OUTPUT=D.KDKEGIATAN LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N'
                                AND SUBSTR(A.AKUN,1,1) IN('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
				 ";

        foreach ($filter as $filter2) {
            $sql .= " AND " . $filter2;
        }
        $sql .= " GROUP BY OUTPUT, d.NMKEGIATAN";
        $sql .= " ORDER BY kode_kegiatan ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }

    
    public function get_ba_per_es1_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT SUBSTR(program,1,5) KODE_KEGIATAN, C.nmes1 NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  "
                . $this->_table4 . " C ON SUBSTR(A.program,1,5)=C.kdes1 LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY SUBSTR(program,1,5), C.nmes1";
        $sql .= " ORDER BY SUBSTR(program,1,5) ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }

   public function get_ba_persates1_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT SUBSTR(program,1,5) KODE_KEGIATAN, C.nmes1 NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  "
                . $this->_table4 . " C ON SUBSTR(A.program,1,5)=C.kdes1 LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        foreach ($filter as $filter1) {
            $sql .= " AND " . $filter1;
        }
        $sql .= " GROUP BY SUBSTR(program,1,5), C.nmes1";
        $sql .=" union all 
                SELECT SUBSTR(program,1,5)||'-'||satker KODE_KEGIATAN, C.nmsatker NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  
                ( SELECT DISTINCT KDSATKER, nmsatker,BA, BAES1 FROM " . $this->_table8.") C ON A.satker=C.kdsatker LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        foreach ($filter as $filter2) {
            $sql .= " AND " . $filter2;
        }
        $sql .= " GROUP BY SUBSTR(program,1,5),satker, C.nmsatker";
        $sql .= " ORDER BY kode_kegiatan ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }
    
    public function get_ba_per_jenbel_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT SUBSTR(akun,1,2) KODE_KEGIATAN, C.NMAKUN NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  
                R_JENBEL C ON SUBSTR(A.akun,1,2)=C.KDAKUN LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY SUBSTR(AKUN,1,2), C.NMAKUN";
        $sql .= " ORDER BY SUBSTR(AKUN,1,2) ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }
    
    public function get_ba_per_sdana_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT SUBSTR(dana,1,1) KODE_KEGIATAN, C.deskripsi NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  
                T_SDANA C ON SUBSTR(A.dana,1,1)=C.kd_sdana LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        $no = 0;
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY SUBSTR(dana,1,1), C.deskripsi";
        $sql .= " ORDER BY SUBSTR(dana,1,1) ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }
  
        public function get_ba_peres1jenbel_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT SUBSTR(program,1,5) KODE_KEGIATAN, C.nmes1 NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  "
                . $this->_table4 . " C ON SUBSTR(A.program,1,5)=C.kdes1 LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        foreach ($filter as $filter1) {
            $sql .= " AND " . $filter1;
        }
        $sql .= " GROUP BY SUBSTR(program,1,5), C.nmes1";
        $sql .=" union all 
                SELECT SUBSTR(program,1,5)||'-'||substr(A.akun,1,2) KODE_KEGIATAN, C.nmakun NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  
                R_JENBEL C ON substr(A.akun,1,2)=C.KDAKUN LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        foreach ($filter as $filter2) {
            $sql .= " AND " . $filter2;
        }
        $sql .= " GROUP BY SUBSTR(program,1,5),SUBSTR(A.AKUN,1,2), C.NMAKUN";
        $sql .= " ORDER BY kode_kegiatan ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }

    public function get_ba_peres1sdana_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT SUBSTR(program,1,5) KODE_KEGIATAN, C.nmes1 NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  "
                . $this->_table4 . " C ON SUBSTR(A.program,1,5)=C.kdes1 LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        foreach ($filter as $filter1) {
            $sql .= " AND " . $filter1;
        }
        $sql .= " GROUP BY SUBSTR(program,1,5), C.nmes1";
        $sql .=" union all 
                SELECT SUBSTR(program,1,5)||'-'||substr(A.dana,1,1) KODE_KEGIATAN, C.deskripsi NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  
                T_SDANA C ON substr(A.DANA,1,1)=C.KD_SDANA LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        foreach ($filter as $filter2) {
            $sql .= " AND " . $filter2;
        }
        $sql .= " GROUP BY SUBSTR(program,1,5),SUBSTR(A.DANA,1,1), C.DESKRIPSI";
        $sql .= " ORDER BY kode_kegiatan ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }

       public function get_es1_persat_filter($filter) {
        Session::get('id_user');
        $sql = " SELECT satker KODE_KEGIATAN, C.nmsatker NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  
                ( SELECT DISTINCT KDSATKER, nmsatker,BA, BAES1 FROM " . $this->_table8.") C ON A.satker=C.kdsatker LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        foreach ($filter as $filter2) {
            $sql .= " AND " . $filter2;
        }
        $sql .= " GROUP BY satker, C.nmsatker";
        $sql .= " ORDER BY kode_kegiatan ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }

    public function get_fa_es1_persatjenbel_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT satker KODE_KEGIATAN, C.nmsatker NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  
                ( SELECT DISTINCT KDSATKER, nmsatker,BA, BAES1 FROM " . $this->_table8.") C ON a.satker=C.kdsatker LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        foreach ($filter as $filter1) {
            $sql .= " AND " . $filter1;
        }
        $sql .= " GROUP BY satker, C.nmsatker";
        $sql .=" union all 
                SELECT satker||'-'||substr(A.akun,1,2) KODE_KEGIATAN, C.nmakun NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  
                R_JENBEL C ON substr(A.akun,1,2)=C.KDAKUN LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        foreach ($filter as $filter2) {
            $sql .= " AND " . $filter2;
        }
        $sql .= " GROUP BY satker,SUBSTR(A.AKUN,1,2), C.NMAKUN";
        $sql .= " ORDER BY kode_kegiatan ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }

        public function get_fa_es1_persatsdana_filter($filter) {
        Session::get('id_user');
        $sql = "SELECT satker KODE_KEGIATAN, C.nmsatker NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  
                ( SELECT DISTINCT KDSATKER, nmsatker,BA, BAES1 FROM " . $this->_table8.") C ON a.satker=C.kdsatker LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        foreach ($filter as $filter1) {
            $sql .= " AND " . $filter1;
        }
        $sql .= " GROUP BY satker, C.nmsatker";
        $sql .=" union all 
                SELECT satker||'-'||substr(A.dana,1,1) KODE_KEGIATAN, C.deskripsi NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  
                T_SDANA C ON substr(A.DANA,1,1)=C.KD_SDANA LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        foreach ($filter as $filter2) {
            $sql .= " AND " . $filter2;
        }
        $sql .= " GROUP BY satker,SUBSTR(A.dana,1,1), C.deskripsi";
        $sql .= " ORDER BY kode_kegiatan ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }
    
    public function get_fa_perba_filter($filter,$filter2) {
        Session::get('id_user');
        $sql = "select a.kode_kegiatan,C.NMBA NMKEGIATAN,sum(a.pagu) pagu,sum(a.realisasi) realisasi,sum(a.obligation) obligation,sum(a.block_amount) block_amount,sum(a.balancing_amt) balancing_amt from (
            SELECT 
            case when satker not like '%Z%' and substr(program,1,3)  in ('ZZZ','000') then 
            (SELECT BA from t_satker_all where kdsatker=satker and rownum=1)
            when satker like '%Z' and substr(program,1,3) in ('ZZZ','000') then substr(satker,1,3)
            else substr(program,1,3)
            end  KODE_KEGIATAN,  BUDGET_AMT PAGU, ACTUAL_AMT REALISASI,
				OBLIGATION, (BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, (BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM "
                . $this->_table1 . " A LEFT JOIN  "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND SUBSTR(A.AKUN,1,1) IN ('5','6')
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) > 0
                                ";
        if (Session::get('role') == KANWIL||Session::get('role') == KPPN) {
        foreach ($filter2 as $filter2) {
            $sql .= " AND " . $filter2;
        }}
        $sql .= ") a left join ". $this->_table2 . " C ON a.kode_kegiatan=C.KDBA "
                . "where 1=1 ";
        foreach ($filter as $filter) {
            $sql .= " AND " . $filter;
        }
        $sql .= " GROUP BY kode_kegiatan,c.nmba ORDER BY kode_kegiatan ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }

        public function get_fa_pembiayaan($filter) {
        Session::get('id_user');
        $sql = "SELECT substr(a.akun,1,2) KODE_KEGIATAN, C.nmakun NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM 
                (select * from " . $this->_table1 . " where akun like '7%') A LEFT JOIN  
                r_jenbel C ON substr(a.akun,1,2)=C.kdakun LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) <> 0
                                ";
        foreach ($filter as $filter1) {
            $sql .= " AND " . $filter1;
        }
        $sql .= " GROUP BY substr(a.akun,1,2), C.nmakun";
        $sql .=" union all 
                SELECT substr(a.akun,1,3) KODE_KEGIATAN, C.nmakun NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM 
                (select * from " . $this->_table1 . " where akun like '7%') A LEFT JOIN  
                r_akun3digit C ON substr(a.akun,1,3)=C.kdakun LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) <> 0
                                ";
        foreach ($filter as $filter2) {
            $sql .= " AND " . $filter2;
        }
        $sql .= " GROUP BY substr(a.akun,1,3), C.nmakun";
        $sql .=" union all 
                SELECT akun KODE_KEGIATAN, C.description NMKEGIATAN, SUM(BUDGET_AMT) PAGU, SUM(ACTUAL_AMT) REALISASI,
				SUM(OBLIGATION) OBLIGATION, SUM(BLOCK_AMOUNT+nvl(B.JMLBLOCK,0)) BLOCK_AMOUNT, SUM(BALANCING_AMT-nvl(B.JMLBLOCK,0)) BALANCING_AMT
                                FROM 
                (select * from " . $this->_table1 . " where akun like '7%') A LEFT JOIN  
                t_akun C ON a.akun=C.flex_value LEFT JOIN "
                . $this->_table7 . " B ON  A.CODE_COMBINATION_ID=B.CCID 
				WHERE 1=1 AND 
				A.BUDGET_TYPE='2' 
				AND A.SUMMARY_FLAG = 'N' 
				AND NVL(A.BUDGET_AMT,0) + NVL(A.ENCUMBRANCE_AMT,0) + NVL(A.ACTUAL_AMT,0) <> 0
                                ";
        foreach ($filter as $filter3) {
            $sql .= " AND " . $filter3;
        }
        $sql .= " GROUP BY a.akun, C.description";

        $sql .= " ORDER BY kode_kegiatan ";

        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }

    public function get_detail_akun_pembiayaan($filter) {
        Session::get('id_user');
        $sql = "select nvl(name,'') kdba,nvl(country,'') nmba, nvl(cred_name,'') kode_kegiatan,a.dana nmkegiatan,sum(nvl(a.budget_amt,0)) pagu ,sum(nvl(a.actual_amt,0)) realisasi from "
            . $this->_table1 . " a left join djpu_register b on substr(a.dana,3,8)=b.reg_no
                where a.budget_type ='2' ";
        foreach ($filter as $filter1) {
            $sql .= " AND " . $filter1;
        }
        $sql .= " group by name,country, cred_name,a.dana
                having sum(nvl(a.budget_amt,0))+sum(nvl(a.actual_amt,0))<>0 
                order by realisasi desc,pagu desc";
 
        //var_dump($sql);
        $result = $this->db->select($sql);
        $data = array();
        foreach ($result as $val) {
            $d_data = new $this($this->registry);
            $d_data->set_satker($val['KDBA']);
            $d_data->set_kdkegiatan($val['KODE_KEGIATAN']);
            $d_data->set_nmkegiatan($val['NMKEGIATAN']);
            $d_data->set_budget_amt($val['PAGU']);
            $d_data->set_actual_amt($val['REALISASI']);
            $d_data->set_nm_satker($val['NMBA']);
            $d_data->set_obligation($val['OBLIGATION']);
            $d_data->set_block_amount($val['BLOCK_AMOUNT']);
            $d_data->set_balancing_amt($val['BALANCING_AMT']);
            $data[] = $d_data;
        }
        return $data;
    }

    /*
     * setter
     */
	public function set_jan($jan) {
        $this->_jan = $jan;
    }
	
	public function set_feb($feb) {
        $this->_feb = $feb;
    }
	
	public function set_mar($mar) {
        $this->_mar = $mar;
    }
	
	public function set_apr($apr) {
        $this->_apr = $apr;
    }
	
	public function set_mei($mei) {
        $this->_mei = $mei;
    }
	
	public function set_jun($jun) {
        $this->_jun = $jun;
    }
	
	public function set_jul($jul) {
        $this->_jul = $jul;
    }
	
	public function set_agt($agt) {
        $this->_agt = $agt;
    }
	
	public function set_sep($sep) {
        $this->_sep = $sep;
    }
	
	public function set_okt($okt) {
        $this->_okt = $okt;
    }
	
	public function set_nov($nov) {
        $this->_nov = $nov;
    }
	
	public function set_des($des) {
        $this->_des = $des;
    }
	
    public function set_obligation($obligation) {
        $this->_obligation = $obligation;
    }

    public function set_block_amount($block_amont) {
        $this->_block_amount = $block_amont;
    }

    public function set_temp_block($temp_block) {
        $this->_temp_block = $temp_block;
    }

    public function set_cash_limit($cash_limit) {
        $this->_cash_limit = $cash_limit;
    }

    public function set_invoice($invoice) {
        $this->_invoice = $invoice;
    }

    public function set_satker($satker) {
        $this->_satker = $satker;
    }

    public function set_kppn($kppn) {
        $this->_kppn = $kppn;
    }

    public function set_nm_satker($nm_satker) {
        $this->_nm_satker = $nm_satker;
    }

    public function set_code_id($code_id) {
        $this->_code_id = $code_id;
    }

    public function set_akun($akun) {
        $this->_akun = $akun;
    }

    public function set_program($program) {
        $this->_program = $program;
    }

    public function set_output($output) {
        $this->_output = $output;
    }

    public function set_dana($dana) {
        $this->_dana = $dana;
    }

    public function set_bank($bank) {
        $this->_bank = $bank;
    }

    public function set_kewenangan($kewenangan) {
        $this->_kewenangan = $kewenangan;
    }

    public function set_lokasi($lokasi) {
        $this->_lokasi = $lokasi;
    }

    public function set_budget_type($budget_type) {
        $this->_budget_type = $budget_type;
    }

    public function set_currency_code($currency_code) {
        $this->_currency_code = $currency_code;
    }

    public function set_budget_amt($budget_amt) {
        $this->_budget_amt = $budget_amt;
    }

    public function set_encumbrance_amt($encumbrance_amt) {
        $this->_encumbrance_amt = $encumbrance_amt;
    }

    public function set_actual_amt($actual_amt) {
        $this->_actual_amt = $actual_amt;
    }

    public function set_balancing_amt($balancing_amt) {
        $this->_balancing_amt = $balancing_amt;
    }

    public function set_kdkegiatan($kdkegiatan) {
        $this->_kdkegiatan = $kdkegiatan;
    }

    public function set_nmkegiatan($nmkegiatan) {
        $this->_nmkegiatan = $nmkegiatan;
    }
	
	public function set_pengembalian($pengembalian) {
        $this->_pengembalian = $pengembalian;
    }
	public function set_tgl($tgl) {
        $this->_tgl = $tgl;
    }
	
	public function set_nodok($nodok) {
        $this->_nodok = $nodok;
    }
	
	public function set_provinsi($provinsi) {
        $this->_provinsi = $provinsi;
    }
	
	
	public function set_nmlokasi($nmlokasi) {
        $this->_nmlokasi = $nmlokasi;
    }
    /*
     * getter
     */
	public function get_jan() {
        return $this->_jan;
    }
	
	public function get_feb() {
        return $this->_feb;
    }
	
	public function get_mar() {
        return $this->_mar;
    }
	
	public function get_apr() {
        return $this->_apr;
    }
	
	public function get_mei() {
        return $this->_mei;
    }
	
	public function get_jun() {
        return $this->_jun;
    }
	
	public function get_jul() {
        return $this->_jul;
    }
	
	public function get_agt() {
        return $this->_agt;
    }
	
	public function get_sep() {
        return $this->_sep;
    }
	
	public function get_okt() {
        return $this->_okt;
    }
	
	public function get_nov() {
        return $this->_nov;
    }
	
	public function get_des() {
        return $this->_des;
    }
    public function get_obligation() {
        return $this->_obligation;
    }

    public function get_block_amount() {
        return $this->_block_amount;
    }

    public function get_temp_block() {
        return $this->_temp_block;
    }

    public function get_cash_limit() {
        return $this->_cash_limit;
    }

    public function get_invoice() {
        return $this->_invoice;
    }

    public function get_nm_satker() {
        return $this->_nm_satker;
    }

    public function get_satker() {
        return $this->_satker;
    }

    public function get_code_id() {
        return $this->_code_id;
    }

    public function get_kppn() {
        return $this->_kppn;
    }

    public function get_akun() {
        return $this->_akun;
    }

    public function get_program() {
        return $this->_program;
    }

    public function get_output() {
        return $this->_output;
    }

    public function get_dana() {
        return $this->_dana;
    }

    public function get_bank() {
        return $this->_bank;
    }

    public function get_kewenangan() {
        return $this->_kewenangan;
    }

    public function get_lokasi() {
        return $this->_lokasi;
    }

    public function get_budget_type() {
        return $this->_budget_type;
    }

    public function get_currency_code() {
        return $this->_currency_code;
    }

    public function get_budget_amt() {
        return $this->_budget_amt;
    }

    public function get_encumbrance_amt() {
        return $this->_encumbrance_amt;
    }

    public function get_actual_amt() {
        return $this->_actual_amt;
    }

    function get_block_revisi() {
        return $this->_block_revisi;
    }

    function set_block_revisi($_block_revisi) {
        $this->_block_revisi = $_block_revisi;
    }

    public function get_balancing_amt() {
        return $this->_balancing_amt;
    }

    public function get_kdkegiatan() {
        return $this->_kdkegiatan;
    }

    public function get_nmkegiatan() {
        return $this->_nmkegiatan;
    }
	public function get_pengembalian() {
        return $this->_pengembalian;
    }
	public function get_tgl() {
        return $this->_tgl;
    }
	public function get_nodok() {
        return $this->_nodok;
    }
	public function get_provinsi() {
        return $this->_provinsi;
    }

	public function get_nmlokasi() {
        return $this->_nmlokasi;
    }
    public function get_table1() {
        return $this->_table1;
    }

    /*
     * destruktor
     */

    public function __destruct() {
        
    }

}
